package com.moody.web;

import java.io.IOException;
import java.io.PrintWriter;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.moody.hibernate.domain.CustInfo;
import com.moody.service.CustomerService;

@Controller
@RequestMapping("/")
public class CheckCustomerController {
	
	ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
	
	@Resource
	private CustomerService customerService;
	
	@RequestMapping("/checkRequest")
	public void checkCustomer(HttpServletRequest request,
			HttpServletResponse response) throws IOException{
		response.setContentType("text/html; charset=utf-8");  
		 response.setHeader("Cache-Control", "no-cache");
		 response.getWriter().print("{success:true}");
	}
	
//	@RequestMapping("/checkMyCustomer")
//	public String checkMyCustomer(HttpServletRequest request,
//			HttpServletResponse response, Model model){
//		
//		request.getSession().removeAttribute("custId");
//		
//		String custId=request.getParameter("CustId");
//		CustInfo selectedCust = new CustInfo();
//		selectedCust = customerService.findCustByCustId(custId); 
//		model.addAttribute("CustInfo", selectedCust);
//		request.getSession().setAttribute("custId", custId);
//		 
//		return "customer/AddCustomer_General";
//	}

}
